/*
 * Blink(Arduino)
 * Turns on an LED on for one second,
 * then off for one second, repeatedly.
 */
#include <Arduino.h>
#include <cupe.h>

uint32_t tick = 0;

void setup()
{
  cupe_init();
  
  pinMode(PC8, OUTPUT|INPUT);
  
  // 使用浮点数
  // 需要是platformio.ini的build_flags中添加 -Wl,-u,_printf_float -Wl,-u,_scanf_float
  // 否则会死机
  // dbLog("float %03.2f\n", 99.323);
}

void loop()
{
  if (millis() - tick > 2000)
  {
    tick = millis();

    digitalWrite(PC8, !digitalRead(PC8));
    dbLog("Hello, world! %lu\n", tick);
  }

  if (cupe_power_key())
  {
    cupe_shutdown();
  }
}
